<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
 require_once 'db_conn.php';
//测试：收集留言，显示出来
/*echo $_POST['username']."<br/>";
echo $_POST['sex']."<br/>";
echo $_POST['message']."<br/>";
echo $_POST['imgurl']."<br/>";*/
 //存入数据库
 $username=$_POST['username'];
 $message=$_POST['message'];
 $sex=$_POST['sex'];
 $imgurl=$_POST['imgurl'];
 //写sql
 $sql="insert into t_message(username,sex,message,imgurl) values('$username','$sex','$message','$imgurl')";
 $result=$db->query($sql);  //
 
 //判断留言是否成功
 if   ($result)
     {
     
                echo "<script language='javascript' type='text/javascript'>";
                echo "alert('留言成功！')：";
                echo "window.location.href='index.php'";
                echo "</script>";
     
 }
 else {
                echo "<script language='javascript' type='text/javascript'>";
                echo "alert('留言失败！')：";
                echo "window.location.href='index.php'";
                echo "</script>";
}
 
 
 
////   header("Location:index.php");

